<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\model\Login;

class Logindo extends Controller
{
	//加载后台登录界面
    public function index()
    {
    	$this->assign('title','后台登录');
    	return view('Index/login');
    }
    //管理员登录
    public function logindo(){
        if(request()->isPost()){
            $res = (new Login())->login(input('post.'));
            if($res['valid'])
            {
                //说明登录成功
                $this->success($res['msg'],'Index/index');
            }else{
                //说明登录失败
                $this->error($res['msg']);exit;
            }
        }else{
            return $this->error('异常访问','Login/index');
        }
    }
    //后台管理员退出
    public function loginout(){
        session('admin',null);
        $this->success("退出成功","Index/login");
    }
}
